package com.sth.guarded;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 * @Author: sitianhong
 * @Description:
 * @Since: create in 2021/6/12 0012 20:00
 */
public class App {
    public static void main(String[] args) throws InterruptedException {
        GuardedQueue guardedQueue = new GuardedQueue();
        ExecutorService executorService = Executors.newFixedThreadPool(3);

        executorService.execute(()->{
            guardedQueue.get();
        });
        Thread.sleep(200);

        executorService.execute(()->{
            guardedQueue.put(20);
        });
        executorService.shutdown();
        executorService.awaitTermination(30, TimeUnit.SECONDS);
    }
}
